package c06_map;
/**
 * 按照年纪降序
 * 如果年纪一样，按照成绩升序
 */

import java.util.Comparator;
import java.util.TreeSet;

public class Test {

    public static void main(String[] args) {
        //1.创建集合，存储学生信息
        TreeSet<Student> students = new TreeSet<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o2.getAge() - o1.getAge();
            }
        });

        //2.添加学生信息`
        students.add(new Student("狗哥", 18, 100));
        students.add(new Student("厂长", 19, 90));
        students.add(new Student("水子哥", 17, 90));
        students.add(new Student("圣枪哥", 18, 99));

        //3.打印结果
        students.forEach(System.out::println);
    }
}
